package edu.gdkm.sql.dao;

import edu.gdkm.sql.pojo.Category;
import edu.gdkm.sql.pojo.Orderdetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderdetailMapper {
    // 查询全部类别
    @Select("select * from orderdetail")
    List<Orderdetail> findAll();
    // 根据id查询类别
    @Select("SELECT * FROM orderdetail WHERE id = #{id}")
    Orderdetail findById(int id);

    // 添加类别
    @Insert("INSERT INTO orderdetail(orderid,productid,count) VALUES(#{orderid},#{productid},#{count})")
    int insertOrderdetail(Orderdetail orderdetail);

    // 更新类别
    @Update("UPDATE orderdetail SET orderid=#{orderid},productid=#{productid},count=#{count} WHERE id=#{id}")
    int updateOrderdetailById(Orderdetail orderdetail);


    // 删除类别
    @Delete("DELETE FROM orderdetail WHERE id=#{id}")
    int deleteOrderdetailById(int id);
}
